#include "include/binformat.h"
#include "include/param.h"
#include "include/defs.h"
#include "include/debug.h"
const int kElfInfoNum = 30;
int CopyString2Stack(char *strs[], struct BinProgram * bin_prog)
{
  int i = 0;
  for (; strs[i]; i++) {
    if (i > MAXARG)
      return -1;
    bin_prog->sp -= strlen(strs[i]) + 1;
    bin_prog->sp -= bin_prog->sp % 16;
    if (bin_prog->sp < bin_prog->stackbase) {
      return -1;
    }
    if (copyout(bin_prog->pagetable, bin_prog->sp, strs[i], strlen(strs[i]) + 1) < 0)
      return -1;
    (bin_prog->ustack)[i] = bin_prog->sp;
  }
  (bin_prog->ustack)[i] = 0;
  return i;
}

uint64 CopyString(const char *s, struct BinProgram * bin_prog)
{
  bin_prog->sp -= strlen(s) + 1;
  bin_prog->sp -= bin_prog->sp % 16;
  if (copyout(bin_prog->pagetable, bin_prog->sp, (char *)s, strlen(s) + 1) < 0)
    return -1;
  return bin_prog->sp;
}
